package cn.ecut.servlet;

import cn.ecut.dao.ContentDao;
import cn.ecut.model.Content;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@WebServlet("/contentTen")
public class ContentTenServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ContentDao contentDao = new ContentDao();
        List<Content> ten = contentDao.ten();
        Map<String, Object> map = new HashMap<>();
        map.put("ten",ten);
        response.getWriter().write(JSON.toJSONString(map));
    }
}
